/*
 * Copyright (c) 2011 Sapienza University of Rome.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 * - Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the
 *   distribution.
 * - Neither the name of the Sapienza University of Rome nor the names of
 *   its contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL SAPIENZA
 * UNIVERSITY OF ROME OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * This interface provides the commands to retrieve or update DISSense schedule information.
 * The interface is implemented by the ManagerC component.
 * @author Ugo Colesanti <colesanti@dis.uniroma1.it>
 * @version 1.01 (September 28, 2011)
 *
 */

interface ScheduleManagement{

			/**
			 * Get the current Sampling Period.
			 * @return The Sampling period (in milliseconds)
			 */
			command uint16_t getCurrentSamplingPeriod() ;

			/**
			 * Get the length of the current Guard Time Interval.
			 * @return The Guard Time Interval (in milliseconds)
			 */
			command uint16_t getCurrentGt() ;

			/**
			 * Get the length of the current Resynchronization Interval.
			 * @return The Resynchronization Interval (in milliseconds)
			 */
			command uint16_t getCurrentRi() ;

			/**
			 * Get the length of the current Data Collection Interval.
			 * @return The Data Collection Interval length in milliseconds.
			 */
			command uint16_t getCurrentDci() ;

			/**
			 * Get the current value of the Skip parameter.
			 * @return The value of the Skip parameter
			 */
			command uint8_t getCurrentSkip() ;

			/**
			 * Get the value of the next Sampling Period (when a new Sampling Period is scheduled,
			 * it remains stored until the new active phase begins).
			 * @return The value, in seconds, of the new Sampling Period
			 */
			command uint16_t getNextSamplingPeriod() ;

			/**
			 * Get the time left until the next active phase with a scheduled  RI begins.
			 * @return The time left, in milliseconds, until the next active phase with a scheduled RI begins
			 */
			command uint32_t getTimeToNextSP() ;

			/*
			 * Get the timestamp at which the next active phase with a scheduled RI begins.
			 * @return The timestamp, expressed in millis, of the next active phase with a scheduled RI
			 */
			command uint32_t getNextSamplingPeriodFired() ;

			/**
			 * Get the length of the Resynchronization Interval that is scheduled.
			 * Note that this is typically different from the current Resynchronization Interval.
			 * @return The length, in milliseconds, of the scheduled Resynchronization Interval
			 */
			command uint16_t getNextRi() ;

			/**
			 * Converts the current Sampling Period, expressed in seconds,
			 * into the current Sampling Period expressed in millis.
			 * @return The current Sampling Period expressed in milliseconds
			 */
			command uint32_t getCurrentSamplingPeriodMilli();

			/**
			 * Set the next Sampling Period (schedule update).
			 * @param nsp The Sampling Period to apply at the next active phase
			 */
			command void setNextSamplingPeriod(uint16_t nsp) ;

			/**
			 * Set the current Sampling Period (initialization).
			 * Sets the current Sampling Period when the node boots or when it receives
			 * a resynchronization message.
			 * @param csp The value, in seconds, of the Sampling Period
			 */
			command void setCurrentSamplingPeriod(uint16_t csp) ;

			/**
			 * Switch from the current Sampling Period to the next Sampling Period (sink only)
			 */
			command void switchToNextSamplingPeriod() ;

			/**
			 * Get the timestamp at which the next active phase begins (may have or not an RI scheduled).
			 * @return The timestamp, expressed in millis, of the next active phase
			 */
			command uint32_t getNextWakeUp() ;

			/**
			 * Set the timestamp (resynchronized) at which the next active phase begins.
			 */
			command void resyncNextWakeUp(uint32_t nwut) ;

			/**
			 * Get the time left until the next active phase begins (may have or not an RI scheduled).
			 * @return The time left, in milliseconds, until the next active phase begins
			 */
			command uint32_t timeToNextWakeUp() ;
}
